/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sims.gui.salesperson;

import sims.entity.User;

/**
 *
 * @author vanthanh
 */
public class SalesPerson extends javax.swing.JFrame {

    /**
     * Creates new form SalesPerson
     */
    
    public SalesPerson() {
        initComponents(); 
        pnMain.removeAll();
        ItemList dis = new ItemList();
        pnMain.add(dis);
        pnMain.validate();
    }
    String userName;
    User user;
    public SalesPerson(User user ) {
        this.user = user;
        initComponents(); 
        this.userName= user.getUsername();
        pnMain.removeAll();
        ItemList dis = new ItemList();
        pnMain.add(dis);
        pnMain.validate();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnMain = new javax.swing.JPanel();
        jMenuBar1 = new javax.swing.JMenuBar();
        menuOrder = new javax.swing.JMenu();
        menuitem_sell = new javax.swing.JMenuItem();
        menu_listorder = new javax.swing.JMenuItem();
        menuitem_displayitem = new javax.swing.JMenu();
        menuDisplayAllItem = new javax.swing.JMenuItem();
        menuUser = new javax.swing.JMenu();
        menuitem_changpass = new javax.swing.JMenuItem();
        menuitem_logout = new javax.swing.JMenuItem();
        munuitem_exit = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Sales Person");

        pnMain.setLayout(new java.awt.BorderLayout());

        menuOrder.setText("Order");
        menuOrder.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        menuitem_sell.setText("Sell");
        menuitem_sell.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuitem_sellActionPerformed(evt);
            }
        });
        menuOrder.add(menuitem_sell);

        menu_listorder.setText("List Order");
        menu_listorder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_listorderActionPerformed(evt);
            }
        });
        menuOrder.add(menu_listorder);

        jMenuBar1.add(menuOrder);

        menuitem_displayitem.setText("Item");
        menuitem_displayitem.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        menuDisplayAllItem.setText("List Item");
        menuDisplayAllItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuDisplayAllItemActionPerformed(evt);
            }
        });
        menuitem_displayitem.add(menuDisplayAllItem);

        jMenuBar1.add(menuitem_displayitem);

        menuUser.setText("User");
        menuUser.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        menuitem_changpass.setText("Change password");
        menuitem_changpass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuitem_changpassActionPerformed(evt);
            }
        });
        menuUser.add(menuitem_changpass);

        menuitem_logout.setText("Log out");
        menuUser.add(menuitem_logout);

        munuitem_exit.setText("Exit");
        menuUser.add(munuitem_exit);

        jMenuBar1.add(menuUser);

        jMenu1.setText("Inform");
        jMenu1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jMenuItem1.setText("Write Inform");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnMain, javax.swing.GroupLayout.DEFAULT_SIZE, 576, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(pnMain, javax.swing.GroupLayout.PREFERRED_SIZE, 508, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void menuitem_sellActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuitem_sellActionPerformed
        
        pnMain.removeAll();
        OrderSell ordersell = new OrderSell(userName);
        pnMain.add(ordersell);
        pnMain.validate();
    }//GEN-LAST:event_menuitem_sellActionPerformed

    private void menuDisplayAllItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuDisplayAllItemActionPerformed
        pnMain.removeAll();
        ItemList dis = new ItemList();
        pnMain.add(dis);
        pnMain.validate();
    }//GEN-LAST:event_menuDisplayAllItemActionPerformed

    private void menu_listorderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_listorderActionPerformed
        pnMain.removeAll();
        ListSellOrder list = new ListSellOrder(userName);
        pnMain.add(list);
        pnMain.validate();
    }//GEN-LAST:event_menu_listorderActionPerformed

    private void menuitem_changpassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuitem_changpassActionPerformed
        pnMain.removeAll();
        ChangePass_GUI list = new ChangePass_GUI(user);
        pnMain.add(list);
        pnMain.validate();
    }//GEN-LAST:event_menuitem_changpassActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        pnMain.removeAll();
        Inform inform = new Inform(user);
        pnMain.add(inform);
        pnMain.validate();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(SalesPerson.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(SalesPerson.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(SalesPerson.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(SalesPerson.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                User u = new User(2, "thanhtv", "e08d83848b858a8b850e050f088838", "sales person");
                new SalesPerson(u).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem menuDisplayAllItem;
    private javax.swing.JMenu menuOrder;
    private javax.swing.JMenu menuUser;
    private javax.swing.JMenuItem menu_listorder;
    private javax.swing.JMenuItem menuitem_changpass;
    private javax.swing.JMenu menuitem_displayitem;
    private javax.swing.JMenuItem menuitem_logout;
    private javax.swing.JMenuItem menuitem_sell;
    private javax.swing.JMenuItem munuitem_exit;
    private javax.swing.JPanel pnMain;
    // End of variables declaration//GEN-END:variables
}
